import request from '@/utils/request.js'

// eslint-disable-next-line camelcase
export const getArticles = (channel_id, timestamp) => {
  // 如果函数没有写return，
  //  它有一个默认的return值，就是undefined
  // return request({
  return request({
    url: 'v1_0/articles', // 接口地址
    method: 'GET',
    // GET：params传参数
    params: {
      channel_id,
      timestamp
    }
  })
}
// 删除文章
export const unLike = (articleId) => {
  return request({
    url: 'v1_0/article/dislikes', // 接口地址
    method: 'POST',
    data: {
      target: articleId
    }
  })
}
// 举报文章
export const report = (articleId, typeId) => {
  return request({
    url: '/v1_0/article/reports', // 接口地址
    method: 'POST',
    data: {
      target: articleId,
      type: typeId
    }
  })
}
// 文章详情
export const getDetail = (articleId) => {
  return request({
    url: 'v1_0/articles/' + articleId, // 接口地址
    method: 'GET'
  })
}
// 取消点赞
export const deleteLike = (id) => {
  return request({
    method: 'DELETE',
    url: 'v1_0/article/likings/' + id
  })
}
// 点赞
export const addLike = (id) => {
  return request({
    method: 'POST',
    url: 'v1_0/article/likings',
    data: {
      target: id
    }
  })
}
